1. Technical Field
The present invention relates in general to a system and method for harvesting zombie processes in an operating system. More particularly, the present invention relates to a system and method for harvesting zombie processes in a UNIX™ type operating system to improve overall system efficiency.
2. Description of the Related Art
In many multitasking operating systems, when a child process (i.e., a process forked, or spawned, from a “parent” process) exits, it becomes a “zombie” process. This is a requirement of many UNIX™ compatible operating systems, as the child's exit value is saved in the child process' control structures themselves so that the parent process can retrieve it.
In modern computer system environments, application programs are written by a variety of vendors. While these application programs interface extensively with the underlying operating system, the operating system generally provides few constraints on the number of child processes generated by application programs, nor whether the application programs efficiently manage their child processes. As a result, many application programs are written in a manner that inefficiently manages child processes. Consequently, extensive operating system resources are often used to clean up after inefficient, or poorly written, application programs.
While zombie processes provide a means for parent processes to retrieve information about child processes that have exited, an abundance of zombie child processes can burden the operating system. When a parent process never requests its children's exit values (via a “wait” system call), and the parent eventually exits, the child processes are re-parented to and eventually cleaned up, or “harvested,” by a standard system process. A standard system process that is often used in a UNIX™ environment is named “init.” Because of the functions it performs, the init process is typically a user process (i.e., not a kernel process) and therefore relatively expensive, in terms of system resources, to execute. This is especially true on larger multi-processor (MP) systems where one init process performs functions, including cleaning up after abandoned children, for processes spawned from several different processors.
FIG. 1 is a prior art diagram showing the interaction between processes in a traditional UNIX™ type of operating system. Swapper process 100 is a kernel process that, among other functions, periodically cleans processes marked as “ignored” out of process table 170. In a traditional UNIX™ system, the swapper process is the parent process of init process 105. The init process is a user process that forks, or spawns, other system processes, daemons, and user processes.
In the example shown, the processes that have been forked by the init process are represented by block 110. In the example, parent process 120 has been forked by init or some other process. Parent process 120 is neither ignoring exit values from its children nor is the parent process waiting on its children's exit values. In a UNIX™ implementation, a parent process that is ignoring SIGCHLD, the death-of-child signal, is ignoring exit values from its children. As used herein, when a process is said to be “ignoring” its child processes, that process (in a UNIX™ implementation) is ignoring the SIGCHLD signal.
Three child processes of parent process 120 are shown: child processes 130, 140, and 150. In the example, the first two child processes, 130 and 140, are “zombie” processes because the child processes exited before parent process 120 exited and the parent failed to act (i.e., the parent failed to either ignore the return values from the child processes or wait on the child processes). The third child process, process 150, was still active when the parent process exited.
In a traditional UNIX™ system, all three processes are re-parented to init process 105 when the parent terminates. This is shown by routine 160 re-parenting child processes 130, 140, and 150 to init whereby they become child processes 170, 180, and 190, respectively. The init process is now responsible for cleaning up (i.e., waiting on) zombie processes 170 and 180. In addition, when active child process 190 eventually exits, the init process will also clean up (i.e., wait on) process 190 as well.
The example shown in FIG. 1 is a simple example showing a few processes being re-parented to init. In an actual system, a very large number of processes may be re-parented to init causing the init process to spend an excessive amount of time cleaning up child processes that were originally created (i.e., forked) by other processes. The excessive amount of time that init spends cleaning up after child processes can burden the system and degrade performance.
What is needed, therefore, is a system and method for efficiently harvesting zombie processes without overburdening system processes, such as init. What is further needed is a system and method for flagging active child processes whose parents have exited, so that, upon their exit, the child processes can be efficiently cleaned from the system.